<?php
/*----------------------------------------------------------------
//功能描述：短信接口处理类
//作者：allen.qiang
//创建时间：2017/05/25
//
//修改历史：
//修改时间：
//修改作者：
//修改功能：
----------------------------------------------------------------*/
namespace Sqapi\Controller;
use Common\BLL\SMSBLL;

class SmsController extends ApiAuthController
{
    //验证码发送
    public function sendValidateCode()
    {
        $mobile = $_POST['mobile'];

        if (empty($mobile)) {
            $this->apiJsonReturn(false, 600);
        }
        $smsbll = new SMSBLL();
        $array = $smsbll->sendValidateCode($mobile);
        $this->apiJsonReturn($array['success'],$array['code']);
    }
    //验证码验证
    public function verifyCode()
    {
        $mobile = $_POST['mobile'];
        $code = $_POST['validateCode'];

        if (empty($mobile) || empty($code)) {
            $this->apiJsonReturn(false, 600);
        }

        $smsbll = new SMSBLL();
        $array = $smsbll->verifyCode($mobile, $code);
        $this->apiJsonReturn($array['success'],$array['code']);
    }

    //短信发送
    public function sendMessage()
    {
        $data = I('post.');
        $mobile = $data['mobile'];
        $sms_code = $data['smsTemplet'];
        $data = $data['data'];

        if (empty($mobile) || empty($sms_code) || empty($data)) {
            $this->apiJsonReturn(false, 600);
        }
        
        $smsbll = new SMSBLL();
        $array = $smsbll->sendMessage($mobile, $sms_code, $data);
        $this->apiJsonReturn($array['success'],$array['code']);
    }


}

